package com.order.server.service;

import com.order.server.mapper.OrderMapper;
import com.order.server.model.OrderInfo;
import com.product.api.ProductApi;
import com.product.api.model.ProductInfo;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper ;

    @Autowired
    private ProductApi productApi ;

    public OrderInfo getById(Integer orderId) {

        OrderInfo orderInfo = orderMapper.getById(orderId);
         // 通过Feign 实现远程调用
        ProductInfo productInfo = productApi.getProductInfo(orderInfo.getProductId());

        orderInfo.setProductInfo(productInfo);
        return orderInfo;
    }
}
